package com.cw.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cw.dao.GenericDao;
import com.cw.po.Res;
import com.cw.service.ResourceService;

@Service("resourceService")
public class ResourceServiceImpl extends BaseServiceImpl<Res> implements
	ResourceService {

	private GenericDao<Res> resourceDao;
	@Override
	@Resource(name = "resourceDao")
	public void setDao(GenericDao<Res> dao) {
		super.setDao(dao);
		this.resourceDao = dao;
	}

	@Override
	public List<Res> findMyRes(Integer id) {
		String hql = "from Res s where s.user.id = ?";
		return resourceDao.findEntityBySql(hql, id);	
	}

	@Override
	public Res getRes(Integer sId) {
		return resourceDao.getEntity(sId);
	}

	@Override
	public void updateRes(Res res) {
		resourceDao.updateEntity(res);
	}

	@Override
	public void deleteRes(Integer sId) {
		String resHql = "delete from Res s where s.id = ?" ;
		resourceDao.batchHandlerByHQL(resHql, sId);	
	}
}
